package com.benjaminwan.read.free.base.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.benjaminwan.read.free.base.activity.BaseActivity
import com.benjaminwan.read.free.utils.RotationMode
import com.benjaminwan.read.free.utils.hideSoftInput

abstract class BaseSimpleFragment : Fragment(),Rotatable {
    //protected lateinit var rootView: View

    //abstract val layoutId: Int

    private val activity: BaseActivity
        get() = requireActivity() as BaseActivity

    override var rotationMode: RotationMode = RotationMode.PORTRAIT

    /*override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? = inflater.inflate(layoutId, container, false).apply {
        this@BaseSimpleFragment.rootView = this
    }*/

    override fun onResume() {
        super.onResume()
        activity.setRotationMode(rotationMode)
    }

    override fun onDestroyView() {
        hideSoftInput()
        super.onDestroyView()
    }
}